﻿using UnityEngine;
using System.Collections;

public class playSounds : MonoBehaviour
{

    public AudioSource ambientMusic;
    public AudioSource playerShipLaser;
    public AudioSource playerShipRocket;
    public AudioSource playerShipMultiLaser;
    public AudioSource playerShipShottyLaser;
    public AudioSource playerShipCluster;
    public AudioSource playerShipVortex;


    public static bool laserShoot = false;
    public static bool rocketShoot = false;
    public static bool clusterShoot = false;
    public static bool vortexShoot = false;
    public static bool MultiLaserShoot = false;
    public static bool ShottyLaserShoot = false;
    // Use this for initialization
    void Start()
    {

        AudioSource[] aSources = GetComponents<AudioSource>();

        //foreach (AudioSource audioRef in aSources){


        ambientMusic = aSources[0];
        playerShipLaser = aSources[1];
        playerShipRocket = aSources[2];
        playerShipMultiLaser = aSources[3];
        playerShipShottyLaser = aSources[4];
        playerShipCluster = aSources[5];
        playerShipVortex = aSources[6];
        ambientMusic.loop = true;
        ambientMusic.Play();

    }

    // Update is called once per frame
    void Update()
    {
        if (Manager.Sound)
        {
            ambientMusic.mute = false;
            //if(Input.GetKey(KeyCode.P)){
        

            //}
            if (laserShoot)
            {
                //playerShipLaser.Play();
                laserShoot = false;

            }
            if (rocketShoot)
            {
                //playerShipRocket.Play();
                rocketShoot = false;

            }
            if (MultiLaserShoot)
            {
                //playerShipMultiLaser.Play();
                MultiLaserShoot = false;

            }
            if (ShottyLaserShoot)
            {
                //playerShipShottyLaser.Play();
                ShottyLaserShoot = false;

            }
            if (vortexShoot)
            {
                //playerShipVortex.Play();
                vortexShoot = false;

            }
            if (clusterShoot)
            {
                //playerShipRocket.Play();
                clusterShoot = false;
            }


        }
        else
        {
            ambientMusic.mute = true;
        }
    }
}
